package com.neu.yth.nepBackend.statistics.client;

import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;

import java.util.Collections;

/**
 * @ClassName MyWebClient
 * @Description
 * @Author YTH
 * @Date 2024-06-26 9:58
 */
@Component
public class MyWebClient {
    @Bean
    public WebClient webClient(){
//        单例模式，只读
        return WebClient.builder()
                .baseUrl("http://localhost:8060")
                .defaultCookie("cookieKey", "cookieValue")
                .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
                .defaultUriVariables(Collections.singletonMap("url", "http://localhost:8030"))

                .build();
    }
}
